package com.jwtproject.bootserver.status;

public enum ProjectStatusEnum {
    /**
     * 请求成功
     */
    SUCCESS(200, "success"),
    /**
     * 登录相关
     */
    USER_ALREADY_REG(600, "该用户已经注册"),

    USER_NOT_EXIST(599,"账户或者密码错误"),

    SYSTEM_IS_BUSY(601,"系统繁忙请稍后重试"),

    COM_IS_OVER(602,"商品已被秒杀完"),

    /**
     * 请求token相关
     */
    TOKEN_ERR(603,"登录时间已过期,请重新登录"),
    TOKEN_IS_NULL(604,"您还未登陆,请重新登录"),
    TOKEN_AUTH_FAILED(604,"认证失败，请重新登录！"),
    /**
     * 服务器异常
     */
    SYS_ERR(500,"服务器异常,请联系管理员"),

    /**
     * 权限相关
     */
    NOT_PERMISSIONS(403,"权限不足");

    /**
     * 系统码
     */
    private int code;


    /**
     * 描述
     */
    private String msg;

    ProjectStatusEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public static ProjectStatusEnum getStatusByKey(int key) {
        for (ProjectStatusEnum t : values()) {
            if (t.getCode() == key) {
                return t;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
